package com.grades.springboot.service.impl;

import com.grades.springboot.service.PermissionVerificationService;
import com.grades.springboot.util.JwtUtil;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;


@Service
public class PermissionVerificationServiceImpl implements PermissionVerificationService {
    @Override
    public Boolean permissionVerification(HttpServletRequest request) {
        String token = request.getHeader("Authorization");
        Map<String,Object> claims = JwtUtil.parseToken(token);
        String userType = (String) claims.get("userType");
        return userType.equals("admin");
    }
}
